package com.hellogood.yaohuo.server.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;

import com.hellogood.yaohuo.server.db.DBHelper;
import com.hellogood.yaohuo.shared.entity.YKDetail;

public class YKDetailDAO extends DBHelper {
	Logger log = Logger.getLogger(this.getClass());

	@Override
	public List<?> initializeObject(ResultSet rs) throws SQLException {
		List<YKDetail> detailList = new ArrayList<YKDetail>();
		if (rs != null) {
			while (rs.next()) {
				YKDetail detail = new YKDetail();
				detail.setYkBillNo(rs.getString("ykBillNo"));
				detail.setOrgCode(rs.getString("orgCode"));
				detail.setPluCode(rs.getString("pluCode"));
				detail.setBarCode(rs.getString("barCode"));
				detail.setDepCode(rs.getString("depCode"));
				detail.setDepName(rs.getString("depName"));
				detail.setPluName(rs.getString("pluName"));
				detail.setBra(rs.getString("bra"));
				detail.setColor(rs.getString("color"));
				detail.setSize(rs.getString("CSize"));
				detail.setjPrice(rs.getBigDecimal("jPrice"));
				detail.setNetJPrice(rs.getBigDecimal("netJPrice"));
				detail.setPrice(rs.getBigDecimal("price"));
				detail.setCounts(rs.getInt("counts"));
				detail.setCost(rs.getBigDecimal("cost"));
				detail.setNetCost(rs.getBigDecimal("netCost"));
				detail.setTotal(rs.getBigDecimal("total"));
				detail.setTimeMark(rs.getString("timeMark"));
				detail.setRzDate(rs.getString("rzDate"));
				detail.setRemark(rs.getString("remark"));
				detailList.add(detail);
			}
		}
		return detailList;
	}

	@SuppressWarnings("unchecked")
	public List<YKDetail> getDetailByBillNo(String billNo) {
		List<YKDetail> list = new ArrayList<YKDetail>();
		String sql = "SELECT * FROM ykDetail WHERE ykBillNo = '" + billNo + "'";
		list = (List<YKDetail>) super.query(sql);
		return list;
	}
}
